package pms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import pms.dao.RaumDao;


/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * @author josef@dr-schneeberger.de
 */
public class FreierRaum extends AbstractController {
	private RaumDao raumDao;

	public void setRaumDao(RaumDao raumDao) {
		this.raumDao = raumDao;
	}
	
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.addObject("title", "Liste Raum");
		mv.addObject("message", "Wählen Sie einen der derzeit verfügbaren Räume:");
		mv.addObject("raum", raumDao.findFreie());
		mv.addObject("edit", false);
		mv.setViewName("list-raum");
		return mv;
	}

}

